import request from '@/utils/request'
import type { ResponseData } from 'dto/globalDto.ts'
import type { UserDto, UserPageDto } from 'dto/acl/user/index.ts'

enum API {
  UserInfo_URL = '/acl/user',
  Users_URL = '/acl/users',
}

/**
 * 通过用户名或者账号搜索
 * @param userName 用户名
 * @param account 账号
 * @returns
 */
export const getUserInfo = (userName?: string, account?: string) =>
  request.get<any, ResponseData<UserDto[]>>(API.UserInfo_URL, {
    params: { userName, account },
  })

/**
 * 获取用户
 * @param page 获取第几页  --默认第一页
 * @param pageSize 每一页的数量
 * @returns
 */
export const getUsers = (page: number, pageSize: number) =>
  request.get<any, ResponseData<UserPageDto>>(API.Users_URL, {
    params: { page, pageSize },
  })
